const { readTask } = require('./ti_logic_read_task');
const {
    httpGet, sleep,
} = require('./util');

(async () => {
    const tasks = await readTask();
    for (let i=30; i<tasks.length; i++) {
        const task = tasks[i];
        if (task.status != 1) continue;
        const serial = task.serial;

        const fullUrl = 'https://www.ti.com.cn/store/ti/zh/p/product/?p='+encodeURIComponent(serial);
        const html = await httpGet(fullUrl);
        const html1 = html.split('breadcrumb_2-')[1];
        const name = html1.split('"')[0];
        console.log(serial, name);

        await sleep(2000);
    }
})();
